{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fc76f90c-8b29-406d-b322-476833d1d0b6",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df = pd.read_csv('./bike_sharing_dc.csv', parse_dates=['date'])\n",
    "\n",
    "import pygwalker as pyg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3b29c804-6385-4d2a-8ab1-fc57ed5c2a03",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mSignature:\u001b[0m\n",
       "\u001b[0mpyg\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwalk\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mdf\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'pl.DataFrame | pd.DataFrame'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mgid\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;34m*\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0menv\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Jupyter'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Streamlit'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'Jupyter'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mfieldSpecs\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDict\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpygwalker\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgwalker_props\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFieldSpec\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mhideDataSourceConfig\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mthemeKey\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'vega'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'g2'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'g2'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mdark\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'media'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'light'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'dark'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'media'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mreturn_html\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mDocstring:\u001b[0m\n",
       "Walk through pandas.DataFrame df with Graphic Walker\n",
       "\n",
       "Args:\n",
       "    - df (pl.DataFrame | pd.DataFrame, optional): dataframe.\n",
       "    - gid (Union[int, str], optional): GraphicWalker container div's id ('gwalker-{gid}')\n",
       "\n",
       "Kargs:\n",
       "    - env: (Literal['Jupyter' | 'Streamlit'], optional): The enviroment using pygwalker. Default as 'Jupyter'\n",
       "    - fieldSpecs (Dict[str, FieldSpec], optional): Specifications of some fields. They'll been automatically inferred from `df` if some fields are not specified.\n",
       "    - hideDataSourceConfig (bool, optional): Hide DataSource import and export button (True) or not (False). Default to True\n",
       "    - themeKey ('vega' | 'g2'): theme type.\n",
       "    - dark (Literal['media' | 'light' | 'dark']): 'media': auto detect OS theme.\n",
       "    - return_html (bool, optional): Directly return a html string. Defaults to False.\n",
       "\u001b[0;31mFile:\u001b[0m      ~/Workspace/develop/pygwalker/pygwalker/gwalker.py\n",
       "\u001b[0;31mType:\u001b[0m      function"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pyg.walk?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "96e6d987-cec6-4dfc-90c0-c586b75ed03e",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mInit signature:\u001b[0m\n",
       "\u001b[0mpyg\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFieldSpec\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0msemanticType\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'?'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'nominal'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'ordinal'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'temporal'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'quantitative'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'?'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0manalyticType\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'?'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'dimension'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'measure'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'?'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mdisplay_as\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mDocstring:\u001b[0m     \n",
       "Field specification.\n",
       "\n",
       "Args:\n",
       "- semanticType: '?' | 'nominal' | 'ordinal' | 'temporal' | 'quantitative'. default to '?'.\n",
       "- analyticType: '?' | 'dimension' | 'measure'. default to '?'.\n",
       "- display_as: str. The field name displayed. None means using the original column name.\n",
       "\u001b[0;31mFile:\u001b[0m           ~/Workspace/develop/pygwalker/pygwalker/utils/gwalker_props.py\n",
       "\u001b[0;31mType:\u001b[0m           type\n",
       "\u001b[0;31mSubclasses:\u001b[0m     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pyg.FieldSpec?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d8c41ab-11ce-4533-8cac-02cb61ea77d5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "pyg.walk(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6e2c88de-418f-41b2-8db0-74877385e126",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pygwalker import FieldSpec\n",
    "field_specs = [\n",
    "    FieldSpec(fname=\"date\", semantic_type=\"temporal\", analytic_type=\"dimension\"),\n",
    "    FieldSpec(fname=\"hour\", semantic_type=\"ordinal\", analytic_type=\"dimension\"),\n",
    "]\n",
    "pyg.walk(df, field_specs=field_specs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d475dc73-93ae-4f18-b41b-2892c5b65eaa",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pygwalker",
   "language": "python",
   "name": "pygwalker"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
